package com.ty.springbootredis;



 import org.junit.Before;
 import org.junit.Test;
 import org.springframework.boot.test.context.SpringBootTest;
 import redis.clients.jedis.Jedis;

/**
 * JedisTester
 *
 * @aurhor Administrator  whs
 * @since 2024/9/25
 */
@SpringBootTest
public class JedisTester {

    private Jedis jedis;

    @Before
    public void setUp(){
        // 连接到服务器
        jedis = new Jedis("127.0.0.1", 6379);
        // 权限指定，指认密码
        jedis.auth("whs");
    }

    @Test
    public void testString() {
        //添加数据
        jedis.set("name", "ktjiaoyu");
        System.out.println(jedis.get("name"));
        jedis.append("name", "czkt");
        System.out.println(jedis.get("name"));
        jedis.del("name");
        System.out.println(jedis.get("name"));
        jedis.mset("name", "ktjiaoyu", "age", "17", "add", "cz");
        jedis.incr("age");
        System.out.println(jedis.get("name") + "-" + jedis.get("age") + "-" + jedis.get("add"));
    }




}
